#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Created by master on 2017/2/25
import smtplib
from email.mime.text import MIMEText
from email.utils import formataddr




def mail(user):
    ret = True
    try:
        msg = MIMEText("邮件内容", "plain", "utf-8")
        msg["From"] = formataddr(["武老师", "wptawy@126.com"])
        msg["To"] = formataddr("23333", "594328762@qq.com")
        msg["Subject"] = "主题"

        server = smtplib.SMTP("smtp.126.com", 25)
        server.login("wptawy@126.com", "ww.3945.59")
        server.sendmail("wptawy@126.com", [user, ], msg.as_string())
        server.quit()
    except Exception:
        ret = False
    return ret


if __name__ == '__main__':
    user = "59432762@qq.com"
    mail(user)
